
from simpleutil.rich_content import SlateRichContentText
from simpleutil.rich_content.slate import LayoutTypeEnum, TableDataAttributesInfo, TableDataNode, TableNode


biaoti_font_size = "16px"
table_font_size = "11pt"
background = "rgb(1, 74, 150)"


def get_content_zhuanjia(info) -> str:
    rich_context = SlateRichContentText()
    rich_context.add_empty_line()
    base_info = rich_context.add_table(margin_left=-180,col_sizes=[180,0])
    base_info.add_row_by_data_nodes([
        TableDataNode(background=background,text="所属公司", font_size=biaoti_font_size,color="white"),
        TableDataNode(text=info['base_info']['gongsi'], font_size=biaoti_font_size)
    ])
    base_info.add_row_by_data_nodes([
        TableDataNode(background=background,text="职务", font_size=biaoti_font_size,color="white"),
        TableDataNode(text=info['base_info']['zhiwu'], font_size=biaoti_font_size)
    ])
    base_info.add_row_by_data_nodes([
        TableDataNode(background=background,text="职称", font_size=biaoti_font_size,color="white"),
        TableDataNode(text=info['base_info']['zhicheng'], font_size=biaoti_font_size)
    ])
    if len(info['zyzg_list'])>0:
        lens = max(len(info['zyzg_list']),1)
        remain = lens-len(info['zyzg_list'])
        if remain > 0:
            for _ in range(remain):
                info['zyzg_list'].append("")
        base_info.add_row_by_data_nodes(data_nodes=[
            TableDataNode(background=background,text="职业资格证书", font_size=biaoti_font_size,color="white",attributes=TableDataAttributesInfo(rowspan=str(lens))),
            TableDataNode(text=info['zyzg_list'][0], font_size=biaoti_font_size)
        ])
        for node in info['zyzg_list'][1:]:
            base_info.add_row_by_data_nodes(data_nodes=[
            TableDataNode(text=node, font_size=biaoti_font_size)
        ])
    base_info.complete()
    lens = max(len(info['scly_list']),2)
    remain = lens-len(info['scly_list'])
    if remain > 0:
        for _ in range(remain):
            info['scly_list'].append("")
    scly = TableNode(margin_left=-180,col_sizes=[180,0])
    scly.add_row_by_data_nodes(data_nodes=[
        TableDataNode(background=background,text="擅长领域", font_size=biaoti_font_size,color="white",attributes=TableDataAttributesInfo(rowspan="2")),
        TableDataNode(text=info['scly_list'][0], font_size=biaoti_font_size)
    ])
    for node in info['scly_list'][1:]:
        scly.add_row_by_data_nodes(data_nodes=[
        TableDataNode(text=node, font_size=biaoti_font_size)
    ])
    scly.complete()
    lens = max(len(info['xffx_list']),2)
    remain = lens-len(info['xffx_list'])
    if remain > 0:
        for _ in range(remain):
            info['xffx_list'].append("")
    xffx = TableNode(margin_left=-180,col_sizes=[180,0])
    xffx.add_row_by_data_nodes(data_nodes=[
        TableDataNode(background=background,text="细分方向", font_size=biaoti_font_size,color="white",attributes=TableDataAttributesInfo(rowspan="2")),
        TableDataNode(text=info['xffx_list'][0], font_size=biaoti_font_size)
    ])
    for node in info['xffx_list'][1:]:
        xffx.add_row_by_data_nodes(data_nodes=[
        TableDataNode(text=node, font_size=biaoti_font_size)
    ])
    xffx.complete()
    layout_node = rich_context.add_layout(LayoutTypeEnum.TWO)
    left_node = layout_node.get_layout_child(0)
    left_node.add_child(scly)
    right_node = layout_node.get_layout_child(1)
    right_node.add_child(xffx)
    rich_context.add_empty_line()
    return rich_context.to_json_str()

def get_content_chuangxin(info) -> str:
    rich_context = SlateRichContentText()
    rich_context.add_empty_line()
    base_info = rich_context.add_table(margin_left=-180,col_sizes=[180,0])
    base_info.add_row_by_data_nodes([
        TableDataNode(background=background,text="所属公司", font_size=biaoti_font_size,color="white"),
        TableDataNode(text=info['base_info']['gongsi'], font_size=biaoti_font_size)
    ])
    base_info.add_row_by_data_nodes([
        TableDataNode(background=background,text="职务", font_size=biaoti_font_size,color="white"),
        TableDataNode(text=info['base_info']['zhiwu'], font_size=biaoti_font_size)
    ])
    base_info.add_row_by_data_nodes([
        TableDataNode(background=background,text="职称", font_size=biaoti_font_size,color="white"),
        TableDataNode(text=info['base_info']['zhicheng'], font_size=biaoti_font_size)
    ])
    if len(info['zyzg_list'])>0:
        lens = max(len(info['zyzg_list']),1)
        remain = lens-len(info['zyzg_list'])
        if remain > 0:
            for _ in range(remain):
                info['zyzg_list'].append("")
        base_info.add_row_by_data_nodes(data_nodes=[
            TableDataNode(background=background,text="职业资格证书", font_size=biaoti_font_size,color="white",attributes=TableDataAttributesInfo(rowspan=str(lens))),
            TableDataNode(text=info['zyzg_list'][0], font_size=biaoti_font_size)
        ])
        for node in info['zyzg_list'][1:]:
            base_info.add_row_by_data_nodes(data_nodes=[
            TableDataNode(text=node, font_size=biaoti_font_size)
        ])
    base_info.complete()
    lens = max(len(info['scly_list']),2)
    remain = lens-len(info['scly_list'])
    if remain > 0:
        for _ in range(remain):
            info['scly_list'].append("")
    scly = TableNode(margin_left=-180,col_sizes=[180,0])
    scly.add_row_by_data_nodes(data_nodes=[
        TableDataNode(background=background,text="专业", font_size=biaoti_font_size,color="white",attributes=TableDataAttributesInfo(rowspan="2")),
        TableDataNode(text=info['scly_list'][0], font_size=biaoti_font_size)
    ])
    for node in info['scly_list'][1:]:
        scly.add_row_by_data_nodes(data_nodes=[
        TableDataNode(text=node, font_size=biaoti_font_size)
    ])
    scly.complete()
    lens = max(len(info['xffx_list']),2)
    remain = lens-len(info['xffx_list'])
    if remain > 0:
        for _ in range(remain):
            info['xffx_list'].append("")
    xffx = TableNode(margin_left=-180,col_sizes=[180,0])
    xffx.add_row_by_data_nodes(data_nodes=[
        TableDataNode(background=background,text="细分专业", font_size=biaoti_font_size,color="white",attributes=TableDataAttributesInfo(rowspan="2")),
        TableDataNode(text=info['xffx_list'][0], font_size=biaoti_font_size)
    ])
    for node in info['xffx_list'][1:]:
        xffx.add_row_by_data_nodes(data_nodes=[
        TableDataNode(text=node, font_size=biaoti_font_size)
    ])
    xffx.complete()
    layout_node = rich_context.add_layout(LayoutTypeEnum.TWO)
    left_node = layout_node.get_layout_child(0)
    left_node.add_child(scly)
    right_node = layout_node.get_layout_child(1)
    right_node.add_child(xffx)
    rich_context.add_empty_line()
    return rich_context.to_json_str()

def get_content_xiangmujishu(info) -> str:
    rich_context = SlateRichContentText()
    rich_context.add_empty_line()
    base_info = rich_context.add_table(margin_left=-180,col_sizes=[180,0])
    base_info.add_row_by_data_nodes([
        TableDataNode(background=background,text="所属公司", font_size=biaoti_font_size,color="white"),
        TableDataNode(text=info['base_info']['gongsi'], font_size=biaoti_font_size)
    ])
    base_info.add_row_by_data_nodes([
        TableDataNode(background=background,text="职务", font_size=biaoti_font_size,color="white"),
        TableDataNode(text=info['base_info']['zhiwu'], font_size=biaoti_font_size)
    ])
    base_info.add_row_by_data_nodes([
        TableDataNode(background=background,text="职称", font_size=biaoti_font_size,color="white"),
        TableDataNode(text=info['base_info']['zhicheng'], font_size=biaoti_font_size)
    ])
    if len(info['zyzg_list'])>0:
        lens = max(len(info['zyzg_list']),1)
        remain = lens-len(info['zyzg_list'])
        if remain > 0:
            for _ in range(remain):
                info['zyzg_list'].append("")
        base_info.add_row_by_data_nodes(data_nodes=[
            TableDataNode(background=background,text="职业资格证书", font_size=biaoti_font_size,color="white",attributes=TableDataAttributesInfo(rowspan=str(lens))),
            TableDataNode(text=info['zyzg_list'][0], font_size=biaoti_font_size)
        ])
        for node in info['zyzg_list'][1:]:
            base_info.add_row_by_data_nodes(data_nodes=[
            TableDataNode(text=node, font_size=biaoti_font_size)
        ])
    base_info.complete()
    lens = max(len(info['scly_list']),2)
    remain = lens-len(info['scly_list'])
    if remain > 0:
        for _ in range(remain):
            info['scly_list'].append("")
    scly = TableNode(margin_left=-180,col_sizes=[180,0])
    scly.add_row_by_data_nodes(data_nodes=[
        TableDataNode(background=background,text="业务", font_size=biaoti_font_size,color="white",attributes=TableDataAttributesInfo(rowspan="2")),
        TableDataNode(text=info['scly_list'][0], font_size=biaoti_font_size)
    ])
    for node in info['scly_list'][1:]:
        scly.add_row_by_data_nodes(data_nodes=[
        TableDataNode(text=node, font_size=biaoti_font_size)
    ])
    scly.complete()
    lens = max(len(info['xffx_list']),2)
    remain = lens-len(info['xffx_list'])
    if remain > 0:
        for _ in range(remain):
            info['xffx_list'].append("")
    xffx = TableNode(margin_left=-180,col_sizes=[180,0])
    xffx.add_row_by_data_nodes(data_nodes=[
        TableDataNode(background=background,text="细分专业", font_size=biaoti_font_size,color="white",attributes=TableDataAttributesInfo(rowspan="2")),
        TableDataNode(text=info['xffx_list'][0], font_size=biaoti_font_size)
    ])
    for node in info['xffx_list'][1:]:
        xffx.add_row_by_data_nodes(data_nodes=[
        TableDataNode(text=node, font_size=biaoti_font_size)
    ])
    xffx.complete()
    layout_node = rich_context.add_layout(LayoutTypeEnum.TWO)
    left_node = layout_node.get_layout_child(0)
    left_node.add_child(scly)
    right_node = layout_node.get_layout_child(1)
    right_node.add_child(xffx)
    rich_context.add_empty_line()
    return rich_context.to_json_str()